﻿using System.Data.Entity.ModelConfiguration;
using eCommerce.Core.Domain.Tradings;

namespace eCommerce.Data.Mapping.Tradings
{
    public class TradingOrderMapping : EntityTypeConfiguration<TradingOrder>
    {
        public TradingOrderMapping()
        {
            this.ToTable("Trading_Order_Mapping");
            this.HasKey(pm => pm.Id);

            this.HasRequired(pm => pm.Order)
                .WithMany(t => t.Tradings)
                .HasForeignKey(pm => pm.OrderId);
            //.WillCascadeOnDelete(false);


            this.HasRequired(pm => pm.Trading)
                .WithMany(t=>t.TradingOrders)
                .HasForeignKey(pm => pm.TradingId);
            //.WillCascadeOnDelete(false);
        }
    }
}